﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Geotools.Geometries;
using System.Windows.Media.Imaging;

namespace AzukiMap.Renderer
{
    public class Tile
    {
        #region fields

        Image _tileImg;

        Uri _uri;
        GTPolygon _orgExtent;
        int _orgWidth;
        int _orgHeight;
        int _orgSrid;
        int _orgDpi;
        double _orgScale;
        CoordinationUnits _orgUnit;

        int _srid;
        int _dpi;
        CoordinationUnits _unit;
        GTPolygon _extent;

        #endregion

        #region  properties
        
        public Image TileImg
        {
            get { return _tileImg; }
        }

        public int OrgTileWidth
        {
            get { return _orgWidth; }
        }

        public int OrgTileHeight
        {
            get { return _orgHeight; }
        }

        public int OrgSrid
        {
            get { return _orgSrid; }
        }

        public int OrgDpi
        {
            get { return _orgDpi; }
        }

        public double OrgScale
        {
            get { return _orgScale; }
        }

        public CoordinationUnits OrgUnit
        {
            get { return _orgUnit; }
        }

        public GTPolygon OrgExtent
        {
            get { return _orgExtent; }
        }

        public Uri Uri
        {
            get { return _uri; }
        }

        public int Srid
        {
            get { return _srid; }
            internal set { _srid = value; }
        }

        public int Dpi
        {
            get { return _dpi; }
            internal set { _dpi = value; }
        }

        public CoordinationUnits Unit
        {
            get { return _unit; }
            internal set { _unit = value; }
        }

        public GTPolygon Extent
        {
            get { return _extent; }
            internal set { _extent = value; }
        }

        #endregion

        public Tile(Uri uri, GTPolygon orgExtent, int orgWidth, int orgHeight, 
            int orgSrid, int orgDpi, double orgScale, CoordinationUnits orgUnit)
        {
            _uri = uri;
            _orgExtent = orgExtent;
            _orgWidth = orgWidth;
            _orgHeight = orgHeight;
            _orgSrid = orgSrid;
            _orgDpi = orgDpi;
            _orgScale = orgScale;
            _orgUnit = orgUnit;
            _tileImg = new Image();

            ImageSource imgsrc = new BitmapImage(uri);
            _tileImg.Source = imgsrc;
        }

    }
}
